package jmine.tec.rpc.server.representers;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

import jmine.tec.rpc.common.annotation.Lazy;
import jmine.tec.rpc.common.entity.AbstractEntityRepresentation;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Representation utilizada para testes de representers.
 * 
 * @author lundberg
 */
public class MockRepresentation extends AbstractEntityRepresentation {

    private BigDecimal number;

    private Boolean bool1;

    private boolean bool2;

    private String string;

    private List<String> stringList;

    private List<BigDecimal> numberList;

    private List<Boolean> booleanList;

    private List<MockRepresentation> objectList;

    private Map<String, MockRepresentation> map;

    private Set<MockRepresentation> set;

    /**
     * @return the number
     */
    public BigDecimal getNumber() {
        return this.number;
    }

    /**
     * @param number the number to set
     */
    public void setNumber(BigDecimal number) {
        this.number = number;
    }

    /**
     * @return the bool1
     */
    public Boolean getBool1() {
        return this.bool1;
    }

    /**
     * @param bool1 the bool1 to set
     */
    public void setBool1(Boolean bool1) {
        this.bool1 = bool1;
    }

    /**
     * @return the bool2
     */
    public boolean isBool2() {
        return this.bool2;
    }

    /**
     * @param bool2 the bool2 to set
     */
    public void setBool2(boolean bool2) {
        this.bool2 = bool2;
    }

    /**
     * @return the string
     */
    public String getString() {
        return this.string;
    }

    /**
     * @param string the string to set
     */
    public void setString(String string) {
        this.string = string;
    }

    /**
     * @return the stringList
     */
    public List<String> getStringList() {
        return this.stringList;
    }

    /**
     * @param stringList the stringList to set
     */
    public void setStringList(List<String> stringList) {
        this.stringList = stringList;
    }

    /**
     * @return the numberList
     */
    public List<BigDecimal> getNumberList() {
        return this.numberList;
    }

    /**
     * @param numberList the numberList to set
     */
    public void setNumberList(List<BigDecimal> numberList) {
        this.numberList = numberList;
    }

    /**
     * @return the booleanList
     */
    public List<Boolean> getBooleanList() {
        return this.booleanList;
    }

    /**
     * @param booleanList the booleanList to set
     */
    public void setBooleanList(List<Boolean> booleanList) {
        this.booleanList = booleanList;
    }

    /**
     * @return the objectList
     */
    @Lazy
    public List<MockRepresentation> getObjectList() {
        return this.objectList;
    }

    /**
     * @param objectList the objectList to set
     */
    public void setObjectList(List<MockRepresentation> objectList) {
        this.objectList = objectList;
    }

    /**
     * @return the map
     */
    @Lazy
    public Map<String, MockRepresentation> getMap() {
        return this.map;
    }

    /**
     * @return the set
     */
    public Set<MockRepresentation> getSet() {
        return this.set;
    }

    /**
     * @param map the map to set
     */
    public void setMap(Map<String, MockRepresentation> map) {
        this.map = map;
    }

    /**
     * @param set the set to set
     */
    public void setSet(Set<MockRepresentation> set) {
        this.set = set;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.bool1 == null) ? 0 : this.bool1.hashCode());
        result = prime * result + (this.bool2 ? 0 : 1);
        result = prime * result + ((this.booleanList == null) ? 0 : this.booleanList.hashCode());
        result = prime * result + ((this.number == null) ? 0 : this.number.hashCode());
        result = prime * result + ((this.numberList == null) ? 0 : this.numberList.hashCode());
        result = prime * result + ((this.objectList == null) ? 0 : this.objectList.hashCode());
        result = prime * result + ((this.string == null) ? 0 : this.string.hashCode());
        result = prime * result + ((this.stringList == null) ? 0 : this.stringList.hashCode());
        result = prime * result + ((this.map == null) ? 0 : this.map.hashCode());
        result = prime * result + ((this.set == null) ? 0 : this.set.hashCode());
        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof MockRepresentation)) {
            return false;
        }
        MockRepresentation other = (MockRepresentation) obj;
        if (this.getBool1() == null) {
            if (other.getBool1() != null) {
                return false;
            }
        } else if (!this.getBool1().equals(other.getBool1())) {
            return false;
        }
        if (this.isBool2() != other.isBool2()) {
            return false;
        }
        if (this.getBooleanList() == null) {
            if (other.getBooleanList() != null) {
                return false;
            }
        } else if (!this.getBooleanList().equals(other.getBooleanList())) {
            return false;
        }
        if (this.getNumber() == null) {
            if (other.getNumber() != null) {
                return false;
            }
        } else if (!this.getNumber().equals(other.getNumber())) {
            return false;
        }
        if (this.getNumberList() == null) {
            if (other.getNumberList() != null) {
                return false;
            }
        } else if (!this.getNumberList().equals(other.getNumberList())) {
            return false;
        }
        if (this.getObjectList() == null) {
            if (other.getObjectList() != null) {
                return false;
            }
        } else if (!this.getObjectList().equals(other.getObjectList())) {
            return false;
        }
        if (this.getString() == null) {
            if (other.getString() != null) {
                return false;
            }
        } else if (!this.getString().equals(other.getString())) {
            return false;
        }
        if (this.getStringList() == null) {
            if (other.getStringList() != null) {
                return false;
            }
        } else if (!this.getStringList().equals(other.getStringList())) {
            return false;
        }
        if (this.getMap() == null) {
            if (other.getMap() != null) {
                return false;
            }
        } else if (!this.getMap().equals(other.getMap())) {
            return false;
        }
        if (this.getSet() == null) {
            if (other.getSet() != null) {
                return false;
            }
            // } else if (new HashSet<Object>(this.getSet()).equals(new HashSet<Object>(other.getSet()))) {
            // return false;
            // }
        }
        return true;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
